<template>
  <view class="success-page" :style="my_style">
    <view class="flex-center fdc">
      <u-icon
        class="icon"
        :color="theme_color"
        name="ic_success"
        custom-prefix="custom-icon"
        size="220"
      />
      <view class="u-font-36 lh-50 font-weight-500 u-text-center u-m-b-48" v-html="info.tip"></view>
      <view class="light-color u-text-center u-m-b-60" v-html="info.desc"></view>
      <view class="u-p-l-24 u-p-r-24 w100" v-if="info.class">
        <text class="footer-primary-btn flex-center" @click="goBack">{{ info.btn }}</text>
      </view>
      <text v-else class="btn" @click="goBack">{{ info.btn }}</text>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        info: {
          title: '',
          tip: '',
          btn: '',
        },
      }
    },
    onLoad(options) {
      console.log(options)
      this.info = JSON.parse(decodeURIComponent(options.info))
      uni.setNavigationBarTitle({
        title: this.info.title,
      })
    },
    onShow() {},
    methods: {
      goBack() {
        if (this.info.link) {
          if (this.info.link === '/pages/index/index') {
            uni.switchTab({
              url: this.info.link,
            })
          } else {
            uni.redirectTo({
              url: this.info.link,
            })
          }
        } else {
          var pages = getCurrentPages()
          if (pages.length > 1) {
            // 上一个页面实例对象
            var prePage = pages[pages.length - 2]
            // 关键在这里,这里面是触发上个界面
            // // #ifdef H5
            // prePage.refreshPage()
            // // #endif
            // // #ifdef MP-WEIXIN||APP-PLUS
            // prePage.$vm.refreshPage()
            // // #endif
          }
          uni.navigateBack()
        }
      },
    },
  }
</script>

<style scoped lang="scss">
  .success-page {
    height: 100%;
    padding-top: 70rpx;
    background-color: #fff;

    .icon {
      margin-bottom: 40rpx;
    }

    .tip {
      margin: 10rpx 0 52rpx;
    }

    .btn {
      padding: 14rpx 36rpx;
      color: #666;
      border: 2rpx solid #666;
      border-radius: 44rpx;
    }
  }
</style>
